<?php
/**
 * 后台:用户管理控制器
 */
namespace App\Http\Controllers\Admin;

use App\Models\User;

class UserController extends BaseController
{

    public function __construct(User $user)
    {
        parent::__construct();
        $this->user = $user;
    }

    /**
     * 后台:显示用户管理列表首页
     */
    public function getIndex(){

        $data = $this->user->getUserList(request());
        return view('admin.user.index',compact('data'));

    }

    /**
     * 后台:接受id,跳转到修改用户页面
     *
     */
    public function getEditUser()
    {
        if(request()){

            $data = $this->user->getUserById(request());
            return view('admin.user.edit',compact('data'));

        }
    }

    //处理编辑医师请求
    public function postEditUser(){

        $res = $this->user->editUser(request());
        return redirect(Url('center/user/index'));

    }

    /**
     * 显示用户添加主页
     */
    public function getAdd(){

        return view('admin.user.add');

    }

    /**
     * 处理删除用户请求
     *
     */
    public function getDelUser(){

        $res = $this->user->delUser(request());
        return ajax_return($res);

    }


    public function getUserInfo(){
        $res = $this->user->getUserById(request());
        return ajax_return($res);
    }

    /*public function postEditUser(){
         $res = $this->user->EditUser(request());
         return ajax_return($res);
    }*/

    /**
     * 获取用户列表
     */
    public function getUserList(){
        $data = $this->user->getUserList(request());
        return ajax_return($data);
    }

    // 用户管理接口
    public function getUserManage(){
         $res = $this->user->getUserManage();
         return ajax_return($res);
    }

}
